package beans;

import mat.Mat;


public class Point
{
	public int x=0;
	public int y=0;
	public int z=0;
	
	public Point(int x, int y, int z)
	{
		this.x = x;
		this.y = y;
		this.z = z;
		
		
	}
	public Point(double x, double y, double z)
	{
		this.x = (int)x;
		this.y = (int)y;
		this.z = (int)z;
	}
	@Override
	public String toString()
	{
		return "[" + x + ", " + y + ", " + z + "]";
	}
	public Point rotate(double xRot, double yRot, double zRot)
	{
		double sinX=Math.sin(xRot);
		double cosX=Math.cos(xRot);
		double sinY=Math.sin(yRot);
		double cosY=Math.cos(yRot);
		double sinZ=Math.sin(zRot);
		double cosZ=Math.cos(zRot);
		double[][]rotXD={{1,0,0,0},{0,cosX, -sinX,0},{0,sinX, cosX,0},{0,0,0,1}};
		double[][]rotYD={{cosY,0,sinY,0},{0,1,0,0},{-sinY, 0, cosY,0},{0,0,0,1}};
		double[][]rotZD={{cosZ, -sinZ,0,0},{sinZ, cosZ,0,0},{0,0,1,0},{0,0,0,1}};

		Mat rotX = new Mat(rotXD);
		Mat rotY = new Mat(rotYD);
		Mat rotZ = new Mat(rotZD);
		
		Mat p = this.getMat();
		p=p.multiply(rotX);
		p=p.multiply(rotY);
		p=p.multiply(rotZ);

		return getPointFromMat(p);
	}
	private Point getPointFromMat(Mat p)
	{
		double[][] pd= p.getData();		
		Point pn= new Point(pd[0][0],pd[0][1],pd[0][2]);
		return pn;
	}
	private Mat getMat()
	{
		double[][] p ={{x,y,z,1}};		
		return new Mat(p);
	}
	
	
}











